package developer.排序算法.冒泡排序;

import java.util.Arrays;

/**
 * @author zhangyongkang
 * @time 2025/7/18 14:02
 * @description
 */
public class MaoPaoSort {
    public static void main(String[] args) {
        int[] arr = {99, 55, 2, 3, 9, 10, 22, 34, 67, 89, 69, 92, 101, 102};
        maopao(arr);
        Arrays.stream(arr).forEach(a -> {
            System.out.println(a);
            System.out.println("--");
        });
    }

    public static void maopao(int[] arr) {
        int length = arr.length;
        for (int i = 0; i < length; i++) {
            //从
            for (int j = 0; j < length - i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
    }
}
